/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EDT.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author ali
 */
public class AjoutFormationForm extends org.apache.struts.action.ActionForm {
    
    private String key;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
    private String grade;
    private String niveau;
    
    private String filiere;

    @Override
    public String toString() {
        return "AjoutFormationForm{" + "key=" + key + ", grade=" + grade + ", niveau=" + niveau + ", filiere=" + filiere + ", parcours=" + parcours + ", type=" + type + ", anneeex=" + anneeex + ", periode=" + periode + '}';
    }


    
    private String parcours;

    private String type;
    private int anneeex;
    
    private int periode;

    public int getPeriode() {
        return periode;
    }

    public void setPeriode(int periode) {
        this.periode = periode;
    }
    
    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getNiveau() {
        return niveau;
    }

    public void setNiveau(String niveau) {
        this.niveau = niveau;
    }

    public String getFiliere() {
        return filiere;
    }

    public void setFiliere(String filiere) {
        this.filiere = filiere;
    }

    public String getParcours() {
        return parcours;
    }

    public void setParcours(String parcours) {
        this.parcours = parcours;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getAnneeex() {
        return anneeex;
    }

    public void setAnneeex(int anneeex) {
        this.anneeex = anneeex;
    }
    
    

    /**
     *
     */
    public AjoutFormationForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        
       
        
        if (  getAnneeex() == 0) {
            errors.add("annee", new ActionMessage("error.annee.required"));
            // TODO: add 'error.name.required' key to your resources
        }
        
        if ( getFiliere()==null || getFiliere().length() == 0 ) {
            errors.add("filiere", new ActionMessage("error.filiere.required"));
            // TODO: add 'error.name.required' key to your resources
        }
       
        if (getParcours()==null ||  getParcours().length() == 0 ) {
            errors.add("parcours", new ActionMessage("error.parcours.required"));
            // TODO: add 'error.name.required' key to your resources
        }
        
        
        
        
        
        
        
        return errors;
    }
}
